﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Zatify.Domain.Data;

namespace Zatify.Domain.Abstract
{
    public interface IZatifyRepository
    {
        spAPI_User_Login_Result LoginUser(string loginName, string password);

        #region Users

        IQueryable<User> Users { get; }
        User GetUserById(int id);
        void UpdateUser(User user);
        void AddUser(User user);
        void UserChangePassword(int userId, string newPassword);
        void UserDeleteById(int id);
        void UsersDeleteByIds(int[] ids);
        void UserChangeStatus(int userId, bool isActive);
        void UsersChangeStatus(int[] userIds, bool isActive);

        User_Register_Result UserRegister(User user);
        User UserGetByToken(Guid token);
        Int32 UserUpdateByToken(Guid token, User user);
        User BusinessUserGetByToken(Guid token);

        List<Category> UserGetCategories(Guid token);
        Int32 UserAddCategories(Guid token, string categoriesIds);
        Int32 UserUpdateCategories(Guid token, string categoriesIds);

        Int32 UserFavoriteBusinessesAdd(Guid token, string businessIds);
        Int32 UserFavoriteBusinessesDelete(Guid token, string businessIds);

        Int32 UserBlockPromotions(Guid token, string promotionIds);
        Int32 UserBlockBusinesses(Guid token, string businessIds);
        Int32 UserBlockCategories(Guid token, string categoryIds);

        #endregion

        #region UserSettings

        UserSettings UserSettingsGetByToken(Guid token);

        Int32 UserSettingsUpdateByToken(Guid token, string settings, string value);

        #endregion

        #region SystemUsers

        IQueryable<SystemUser> SystemUsers { get; }
        void SystemUserAdd(SystemUser user);
        void SystemUserUpdate(SystemUser user);
        void SystemUserChangePassword(int userId, string newPassword);
        void SystemUserDeleteById(int id);
        void SystemUsersDeleteByIds(int[] ids);
        void SystemUserChangeStatus(int userId, bool isActive);
        void SystemUsersChangeStatus(int[] userIds, bool isActive);

        #endregion

        #region Rates

        IQueryable<BaseCostTiming> BaseCostTimings { get; }
        void BaseCostTimingsUpdate(ICollection<BaseCostTiming> baseCostTimings);

        IQueryable<ProximityRadius> ProximityRadiuses { get; }
        void ProximityRadiusesUpdate(ICollection<ProximityRadius> proximityRadiuses);

        IQueryable<ProximityRadiusOutside> ProximityRadiusesOutside { get; }
        void ProximityRadiusesOutsideUpdate(ICollection<ProximityRadiusOutside> proximityRadiusesOutside);

        ProximityRadius ProximityRadiusGetById(int id);

        #endregion

        #region Defaults

        IQueryable<SystemDefault> SystemDefaults { get; }
        void SystemDefaultUpdate(string parameterCode, string value);

        TimeSpan SystemDefaultsGetBusinessHourFrom();
        TimeSpan SystemDefaultsGetBusinessHourTo();

        #endregion

        #region Categories

        IQueryable<Category> Categories { get; }
        void CategoriesAdd(Category category);
        void CategoriesUpdate(Category category);
        void CategoriesDelete(int id);
        void CategoriesDeleteSelected(string ids);

        IQueryable<Category> CategoriesGetAll();

        void CategoryMove(int categoryId, int? parentCategoryId);

        #endregion

        #region CategoriesRequest

        IQueryable<CategoryRequest> CategoryRequests { get; }
        void CategoryRequestDelete(int[] categoryRequestIds);
        void CategoryRequestConfirm(int categoryRequestId, int? parentCategoryId);

        #endregion

        #region Messages

        IQueryable<Message> MessagesGetInboxMessages(string loginName);
        IQueryable<Message> MessagesGetOutboxMessages(string loginName);
        Message MessagesGetById(int messageId);
        void MessagesAdd(Message message);

        void MessagesAddToAllUsers(Message message);
        void MessagesAddToBusinessUsers(Message message);
        void MessagesAddToEndUsers(Message message);

        void MessagesSetStatus(int messageId, string status);
        void MessagesDeleteInboxById(int messageId);
        void MessagesDeleteOutboxById(int messageId);

        #endregion

        #region Business

        IQueryable<Business> Businesses { get; }
        Business BusinessGetById(int id);
        Business BusinessGetByToken(Guid token);
        void BusinessUpdate(Business business, BusinessHours businessHours, List<Category> categories);
        Int32 BusinessUpdate(Guid token, Business business, BusinessHours businessHours, string categoriesIds, string categoryNewName1, string categoryNewName2, string categoryNewName3,
            double? latitude, double? longitude, int? gmt);
        void BusinessAdd(Business business);
        void BusinessDeleteById(int businessId);
        void BusinessesDeleteByIds(int[] ids);
        void BusinessDeleteCategories(int businessId, string categoriesIds);
        void BusinessChangePassword(int businessId, string newPassword);
        void BusinessChangeStatus(int businessId, bool isActive);
        void BusinessesChangeStatus(int[] businessesIds, bool isActive);

        BusinessHours BusinessGetBusinessHours(int businessId);
        BusinessHoursToday BusinessGetBusinessHoursToday(int businessId);
        IQueryable<Category> BusinessGetCategories(int businessId);

        IQueryable<BusinessBilling> BusinessGetBilling(int businessId, DateTime? dateOperation);

        bool BusinessIsBusinessLoginFree(string login);

        IQueryable<Business> BusinessesSearch(Guid token, string search, double? latitude, double? longitude);
        IQueryable<Business> BusinessesGetUserNearby(Guid token, string zipCode);
        IQueryable<Business> BusinessesGetUserFavorites(Guid token, double? latitude, double? longitude);

        IQueryable<BusinessReview> BusinessGetReviews(Guid token, int businessId);
        Int32 BusinessReviewAdd(Guid token, int businessId, string reviewText, int rating);

        spAPI_Promotion_Add_Result Business_AddPromotion(Guid token);

        spAPI_PromotionCategory_Add_Result Business_AddPromotionCategories(Guid token, int promotionId, string categoriesIds);

        bool Business_IsBusiness24Open(int id);

        IQueryable<Promotion> BusinessGetAllActivePromotions(Guid token, int businessId, double? latitude, double? longitude);

        #endregion

        #region BusinessRegistration

        bool BusinessUser_CheckLoginEmail(string login, string email);

        BusinessRegistrationResult Business_RegisterStep1(string login, string password, string email, string businessName, string web, string businessPhone, string cellPhone,
            string tollFreePhone, string fax, string streetAddress, string streetAddress2, string city, string state, string zip, double? longitude, double? latitude, int? gmt);

        Int32 Business_RegisterStep1Update(Guid token, string password, string email, string businessName, string web, string businessPhone, string cellPhone,
            string tollFreePhone, string fax, string streetAddress, string streetAddress2, string city, string state, string zip, double? longitude, double? latitude, int? gmt);

        Int32 Business_RegisterStep2(Guid token, string description, string referencedBy,
           BusinessHours businessHours, string categoriesIds, string newCategoryName1, string newCategoryName2, string newCategoryName3,
           string creditCardNo, DateTime creditCardExpDate, string creditCardName, string creditCardPin, bool useBusinessAddress, string billingStreetAddress, string billingStreetAddress2,
           string billingCity, string billingState, string billingZip,
           string pictureContentType, byte[] picture,
           double? latitude, double? longitude);

        #endregion

        #region Promotions

        IQueryable<Promotion> PromotionsGetList(int businessId);
        IQueryable<Promotion> PromotionsGetByBusinessToken(Guid token);
        Int32 PromotionDeleteByBusinessTokenAndId(Guid token, int promotionId);
        Promotion PromotionGetByTokenAndId(Guid token, int promotionId);
        Promotion PromotionGetById(int id);
        IQueryable<Category> PromotionGetCategoriesByPromotionId(int promotionId);
        IQueryable<Promotion> Deals(Guid token, double? latitude, double? longitude);

        Int32 Promotion_ProximityRadius_Update(Guid token, int promotionId, int proximityRadiusId, int? customRange,
            bool over200MilesFlag, bool registeredOutsideOfZip, bool registeredOutsideOfState, bool registeredOutsideOfCity);

        Int32 Promotion_BaseCostTiming_Update(Guid token, int promotionId, int baseCostTimingId, DateTime? baseCostTimingScheduledAt,
            DateTime? baseCostTimingStarts, DateTime? baseCostTimingEnds, DateTime? baseCostTimingStartsWithinDay, DateTime? baseCostTimingEndsWithinDay);

        Int32 Promotion_BudgetAdd(Guid token, int promotionId, decimal summaPay, decimal summaRest, string promoName, string promoText, byte[] picture, string pictureContentType);

        Int32 Promotion_Submit(Guid token, int promotionId, decimal summaPay, decimal summaRest);

        Int32 Promotion_Stop(Guid token, int promotionId);

        Int32 Promotion_UpdateTiming(Guid token, int promotionId, int baseCostTimingId, DateTime? baseCostTimingScheduledAt,
            DateTime? baseCostTimingStarts, DateTime? baseCostTimingEnds, DateTime? baseCostTimingStartsWithinDay, DateTime? baseCostTimingEndsWithinDay);

        Int32 Promotion_UpdateBudget(Guid token, int promotionId, decimal compaignBudget, string promotionName, string promotionText, byte[] picture, string pictureContentType, bool? singleUseOnly, string match);

        spAPI_Promotion_GetPayInfo_Result Promotion_GetPayInfo_Result(Guid token, int promotionId);

        string Promotion_Charge(string cardNumber, string cardPin, DateTime cardDateExpiration, decimal amount, string description);

        #endregion

        #region US States

        IQueryable<USState> USStates { get; }

        #endregion

        #region REPORTS

        List<Report_UserReferrer_Result> UserReferrerReport(DateTime? dateFrom, DateTime? dateTo, string referredByID, string referredID);

        #endregion

        #region Billing

        List<BillingTransactionHistory> BillingTransactionHistoryGet(Guid token, int? promotionId, DateTime? dateOperation);

        List<BillingTransactionHistoryForPromotion> BillingTransactionHistoryForPromotionGet(Guid token, int? promotionId, DateTime? dateOperation);

        //spAPI_Billing_Transaction_GetCreditCardTransaction_Result BillingTransactionDetails_CreditCard(Guid token, int transactionId);

        //spAPI_Billing_Transaction_GetPromotionTransaction_Result BillingTransactionDetails_DeditCard(Guid token, int promotionId, DateTime date);

        #endregion

        #region Contacting

        sp_API_User_SendMessage_Result ContactUs_SendMessage(Guid token, string message);

        #endregion

        #region GeoLocation

        List<GeoLocation> GeoLocation_GetList();

        GeoLocation GeoLocation_GetByZipCode(string zipCode);

        GeoLocation Business_GetCoordinates(string streetAddress, string streetAddress2, string city, string state, string zip);

        #endregion
    }
}
